<!--
 * @Author: HeAo
 * @Date: 2021-12-29 10:35:02
 * @LastEditTime: 2021-12-29 10:46:49
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \study\day04\5-监听器.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>
  <div id="app">
    <button @click="msg = 'hello watch'">修改msg</button>
    <div>
      {{msg}}
    </div>
    <input type="text" v-model="inputValue">
    {{inputValue}}
  </div>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        msg: 'hello vue',
        inputValue: ''
      },
      watch: {
        msg(newValue, oldValue) {
          console.log('msg改变', oldValue, newValue);
        },
        inputValue(newValue, oldValue) {
          console.log('输入了关键字:', newValue);
        }
      }
    })
  </script>
</body>

</html>